package com.qdu.mapper;

import com.qdu.bean.WeatherBean1;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class AvgPerHourByWeatherMapper extends Mapper<LongWritable, Text, Text, WeatherBean1> {

    private Text k = new Text();
    private WeatherBean1 v = new WeatherBean1();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        String[] items = value.toString().split(",");

//        int weather = Integer.parseInt(items[4]);      //天气标志
        String weather = items[4];                    //天气标志
        int casual = Integer.parseInt(items[9]);      //未注册的人数
        int registered = Integer.parseInt(items[10]); //注册了的人数

        k.set(weather);
        v.set(registered,casual);

        context.write(k,v);
    }
}
